package com.example.service.impl;

import com.example.mapper.BrandMapper;
import com.example.pojo.Brand;
import com.example.pojo.PageBean;
import com.example.pojo.Supplier;
import com.example.service.BrandService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandMapper brandMapper;


    @Override
    public PageBean getBrand(Brand brand, Integer page, Integer pageSize) {
        //设置分页参数
        PageHelper.startPage(page,pageSize);
        List<Brand> list = brandMapper.getBrand(brand);
        Page<Brand> p= (Page<Brand>) list;
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    @Override
    public List<Brand> getBrandList() {
        return brandMapper.getBrandList();
    }

    @Override
    public void deleteBrand(String id) { brandMapper.deleteBrand(id);}

    @Override
    public void addBrand(Brand brand) { brandMapper.addBrand(brand);
    }

    @Override
    public void changeBrand(Brand brand) { brandMapper.changeBrand(brand);
    }
}
